﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.Regions;
using Castle.Windsor;
using Castle.MicroKernel.Registration;
using Tanmia.Basis.ServiceInterface;

namespace SaryaAccounting
{
    public class StoreModule : IModule
    {
        private readonly IRegionManager regionManager;
        private readonly IWindsorContainer container;
        private readonly INavigationService navigationService;

        public StoreModule(IRegionManager regionManager, IWindsorContainer container, INavigationService navigationService)
        {
            this.regionManager = regionManager;
            this.container = container;
            this.navigationService = navigationService;
        }

        #region IModule Members

        public void Initialize()
        {
            NavigationItem storeModule = new NavigationItem();
            storeModule.Title = "Store";
            storeModule.Description = "Manage the store and items quantity.";
            navigationService.RegisterNavigatorItem(storeModule);

            NavigationItem addStore = new NavigationItem();
            addStore.Title = "Add new store...";
            addStore.ViewName = "EditStore";
            addStore.RegionName = "WindowRegion";
            addStore.Description = "Adding new store to the database.";
            addStore.Parent = storeModule;
            navigationService.RegisterNavigatorItem(addStore);

            NavigationItem brosweStore = new NavigationItem();
            brosweStore.Title = "Browse stores";
            brosweStore.Description = "Browsing all stores in the database.";
            brosweStore.Parent = storeModule;
            navigationService.RegisterNavigatorItem(brosweStore);

            container.Register(Component.For(typeof(Views.EditStore)).Named("EditStore"));
        }

        #endregion
    }
}
